package com.yzd.learnjava.io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class ChannelCopy {
	private static final int BSIZE = 1024;
	public static void main(String[] args) throws IOException {
		FileChannel in = new FileInputStream("test.out").getChannel();
		FileChannel out = new FileOutputStream("test3.out").getChannel();
		
		ByteBuffer bf = ByteBuffer.allocate(BSIZE);
		while(in.read(bf) != -1) {
			bf.flip();
			out.write(bf);
			bf.clear();
		}
	}
}
